﻿using System;
using System.ComponentModel.DataAnnotations;
using System.Linq;

namespace e_TicaretSistemi.Models
{
    public class CustomerValidation
    {
        [Required(ErrorMessage = "Boş Bırakmayınız.")]
        public string EmailAdress { get; set; }
        [Required(ErrorMessage = "Boş Bırakmayınız.")]
        public string Password { get; set; }
    }

    [MetadataType(typeof(CustomerValidation))]
    public partial class Customer
    {
        public static SmDbDataContext Db = new SmDbDataContext();
        private double total;
        public double GetTotalBasketValue()
        {
            try
            {
                total = Db.CustomerOfBaskets.Sum(p => (p.Product.Price * p.Product.Kdv) / 100 + p.Product.Price);
            }
            catch (Exception)
            {

                total = 0;
            }
            return total;
        }
    }
}